<?php

namespace common\model;

use think\model\RelationModel;

/**
 * 租户职位表
 */
class TenantPositionModel extends RelationModel
{
    //自动验证
    protected $_validate = [
        ['name', '', '', self::MUST_VALIDATE, 'require', self::MODEL_INSERT],//必须字段
        ['tenant_id', '', '', self::EXISTS_VALIDATE, 'integer', self::MODEL_BOTH],//必须字段
    ];

    // 自动完成
    protected $_auto = [
        ['tenant_id', 'auto_fill_tenant_id_with_data', self::MODEL_INSERT, 'function_with_data'],
        ['created', 'time', self::MODEL_INSERT, 'function'],
        ['created_by', 'fill_created_by', self::MODEL_INSERT, 'function'],
        ['updated', 'time', self::MODEL_BOTH, 'function'],
    ];

    protected $_validate_after_auto = [
        ['tenant_id,name', '', '', self::MUST_VALIDATE, 'unique'],// 租户内职位名称唯一
    ];
}
